home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / XL7PIW (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.3 KB  |  57 lines

  1. package com.sun.java.swing;
  2.  
  3. import com.sun.java.swing.plaf.IconUIResource;
  4. import java.io.BufferedInputStream;
  5. import java.io.ByteArrayOutputStream;
  6. import java.io.FilterInputStream;
  7. import java.io.IOException;
  8. import java.io.InputStream;
  9. import java.io.OutputStream;
  10.  
  11. class LookAndFeel$1 implements UIDefaults.LazyValue {
  12.    // $FF: synthetic field
  13.    Class val$baseClass;
  14.    // $FF: synthetic field
  15.    String val$gifFile;
  16.  
  17.    public Object createValue(UIDefaults table) {
  18.       byte[] buffer = null;
  19.  
  20.       try {
  21.          InputStream resource = this.val$baseClass.getResourceAsStream(this.val$gifFile);
  22.          if (resource == null) {
  23.             System.err.println(this.val$baseClass.getName() + "/" + this.val$gifFile + " not found.");
  24.             return null;
  25.          }
  26.  
  27.          BufferedInputStream in = new BufferedInputStream(resource);
  28.          ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
  29.          buffer = new byte[1024];
  30.  
  31.          int n;
  32.          while((n = ((FilterInputStream)in).read(buffer)) > 0) {
  33.             out.write(buffer, 0, n);
  34.          }
  35.  
  36.          ((FilterInputStream)in).close();
  37.          ((OutputStream)out).flush();
  38.          buffer = out.toByteArray();
  39.          if (buffer.length == 0) {
  40.             System.err.println("warning: " + this.val$gifFile + " is zero-length");
  41.             return null;
  42.          }
  43.       } catch (IOException var7) {
  44.          System.err.println(((Throwable)var7).toString());
  45.          return null;
  46.       }
  47.  
  48.       return new IconUIResource(new ImageIcon(buffer));
  49.    }
  50.  
  51.    // $FF: synthetic method
  52.    LookAndFeel$1(Class val$baseClass, String val$gifFile) {
  53.       this.val$baseClass = val$baseClass;
  54.       this.val$gifFile = val$gifFile;
  55.    }
  56. }
  57.